import { AxiosResponse } from "axios"
import { Result } from "../interfaces/PublicInterfaces"
import { NAME_Of_TOKEN } from "../interfaces/PublicInterfaces"

export default (response:AxiosResponse<Result<any>>)=>{
    const data = response.data
    const status_code = data.status_code
    // Fail
    if(status_code === 422){

        // handle ...
        return response
    }

    // success
    const refresh_token = data.refresh_token
    if(data.refresh_token !== null){
        localStorage.setItem(NAME_Of_TOKEN, refresh_token)
    }

    return response
}